Contents
Contents for Explore Visual Basic  Help

How to Use Explore Visual Basic

Summary of  Explore Visual Basic - Part 1

Summary of  Explore Visual Basic - Part 2

Summary of Explore Visual Basic - Part 3

Summary of  Explore Visual Basic - Part 4

Summary of  Explore Visual Basic - Part 5

Summary of Explore Visual Basic - Part 6

Summary of Help About... (Form 7 )

Summary of Help Training... (Form 8)


What Is Explore Visual Basic?
What is Explore Visual Basic and how do I use it?

Read the Explore Visual Basic  Overview help topic to find out.


Summary Part 1
Summary of Explore Visual Basic - Part 1

Controls

This form contains examples of text boxes, a frame, labels and menus.

Code

The controls on this form are pretty simple but the form for Part 1 isn't very efficient.  There is no use of control arrays on this form.

There are some useful things to be found in the code, however.

There is an example of reading a file into a text box in  the Form_Load event.

The resize event  contains some code to define all controls as a function of the form size.  This allows for some proportional adjustment of the size and placement or controls when the user resizes the form.  It can be quite a bit of work to do this.

One alternative to all the work is to specify a "Fixed" border style that will not allow the user to change the size of the form.  This alternative was chosen for Forms 2-6.

Explore Visual Basic - Part 1


Summary Part 2
Summary of Explore Visual Basic - Part 2

Controls

This form contains an example of how you can  use a  picture box to produce simple animation effects.

Code

The animation is accomplished by using a For loop to load a series of images from invisible picture boxes on this form into Picture1.  In order for the animation to run slowly enough for the application user to see it, an inner "wait" loop is entered each time the picture is changed.

An attempt is made to move toward more efficient programming techniques by starting to use control arrays and menu control arrays on Form 2.  This effort will increase on subsequent forms.

Explore Visual Basic - Part 2


Summary Part 3
Summary of Explore Visual Basic - Part 3

Controls

This form contains examples of option buttons (both on the form and grouped inside a frame), check boxes, and a command button.

Code

In the code for Part 3 one control's event procedure calls another control's event procedure to avoid having to include the same code in two places.

Explore Visual Basic - Part 3


Summary Part 4
Summary of Explore Visual Basic - Part 4

Controls

This form contains an example of how to synchronize a drive list box, directory list box, and a file list box.

Code

Part 4 shows how to synchronize a drive, directory and file list box.  In the Drive1_Change event there is an example of some simple handling of a hardware error, as well as an example of creating a message box to display the error message.

Explore Visual Basic - Part 4


Summary Part 5
Summary of Explore Visual Basic - Part 5

Controls

This form contains examples of a list box and all three styles of combo boxes.

Code

Part 5  shows how to use the AddItem method for list and combo boxes.  It also has examples of the Got_Focus event procedure and the SetFocus method.

Explore Visual Basic - Part 5


Summary Part 6
Summary of Explore Visual Basic - Part 6

Controls

This form contains examples of vertical and horizontal scroll bars, a timer,  and a very simple flashing animation technique using an icon in a picture box.

Code

Part 6 shows how to vary the Interval and Enabled properties of a timer at run time and demonstrates using a horizontal scroll bar to change the timer interval and a vertical scroll bar to change the size of  the picture box.

Explore Visual Basic - Part 6


Summary Help About...
Help About... (Form 7)

Controls

The About... form contains a picture box, a frame, various labels and a command button.

Code

Form 7 is actually the startup form for the application.  All other forms are loaded in the Form_Load event for this form.  This makes the startup seem a bit slow. (You probably noticed!)  Nevertheless, response time once the application has been started is improved by using this method.  The name for the help file for the application is also set during Form_Load.

 Notice the use of the Environ$ method.  The installation notes for this application mentioned that you would have to add the command:

SET MAXWINVB = <DRIVE>:\MAXWIN\VB

to your AUTOEXEC.BAT file so this application would run successfully.  You will need to replace <DRIVE> in the above command with the letter of the drive where you installed the Explore Visual Basic files.  If you changed the directory path as well, you will, of course, have to change the above command to match the correct path.


Summary Help Training...
Help Training... (Form 8)

Controls

The Training... form contains a picture box,  various labels and a command button.

Code

The only code associated with this form is in the click event for the OK button.  It simply causes the form to hide itself.


How to Use Explore Visual Basic

An Overview of the Application

Explore Visual Basic consists of a series of forms (Forms 1-6) which are designed to be viewed along with the corresponding help topic for that form.  As you move from form to form, the appropriate help topic is displayed to the right of the form.  The help topic will give you some suggestions of things to try on the form. You will sometimes find instructions on the form itself.

 If you close the Help window and then decide you wish to view the help for the form later, choose the topic "About this form" from the Help menu.

There are also two smaller forms that display information in response to  the items Training... (Form 8) and About... (Form 7) on the Help menu.

There are also two modules in the project with no related forms:

EXPLORE.GBL - The global module which contains declarations for variables and constants used throughout the application.

CMNPROCS.BAS - which contains three general procedures which are called from Forms 1-6.  One routine calls help with the appropriate topic, another provides the code for the Next and Back "buttons" (actually labels), and the last notifies WinHelp its okay to close the help window and closes the application.  By placing these three routines in a separate module they are available throughout the application from all forms.

Moving from Form to Form

In the lower right-hand corner of each of the forms you'll find navigation button(s) that will allow you to move back and forth between the forms.

Viewing the Project

Once you have followed the exploration suggestions given concerning the form in the Help topics, you may wish to look at the project itself. If you  have Visual Basic installed, you can choose Open Project from the File menu.  The name of the Project File is EXPLORE.MAK.

If you don't have Visual Basic installed, you can look at a text file  called EXPLORE.COD which is also found in the same directory as the other application files.

Exiting the Application

Any time you wish to exit Explore Visual Basic simply choose Exit from the File menu.


About Explore Visual Basic - Part 1

Changing the Mouse Pointer

You may notice as you move your mouse over certain parts of the form that your mouse pointer changes.

When the mouse is over either one of the "Multiline =" labels it changes to a box within a box.

Place your mouse over one of these labels and see it change shape.

This is done by setting the MousePointer property to 4 (an "Icon") for these two controls.

The label in the bottom right-hand corner of the form with the caption "Next" has its MousePointer value set to 10 (an "Up Arrow").

Move your cursor over this control to see what the "Up Arrow" looks like.

When your mouse is inside a text box, the mouse pointer changes to an "I-Beam" or text cursor.  This is handled automatically for you by Visual Basic to indicate that you can enter or change text in this area.  You do not have to set any properties yourself to accomplish this.

MultiLine Text Boxes

Notice that there are two types of text boxes inside the frame captioned "Two Types of Text Boxes" on this form.

The text box labeled "MultiLine = False" is "tall enough" to hold multiple lines, but since the MultiLine property still has the default value of "False," the text is not wrapped.

You can still see the entire contents of the line by clicking inside the text box to activate your cursor there. Then use the right arrow or End key to move along the line to the end.

Try it.

The text box labeled "MultiLine = True" does have the MultiLine property set to "True."  It also has the ScrollBar property set for a Vertical scroll bar.  The advantage of using just a vertical scroll bar with no horizontal scroll bar is that text will wrap automatically at the right "margin" of the text box.

Click the scroll bar until you've viewed the entire contents of the text box.

Menus

Notice that you have three menus on this form:

File

Whenever you want to close the Explore Visual Basic application just choose Exit from the File menu.

Settings, and

Help.

Select the Settings menu.  Notice that it has a submenu that allows you to set the background color of your form.

Select the Background color submenu by clicking the menu.

You have the choice to set the background color of your form to either white or yellow. The menu item currently selected has a check mark next to it.

Try changing the background color of your form.  Then change it back again.

Try the different options on the Help menu to see what the effect is for each one.

Moving on

When you're done exploring this form, click the area marked Next in the lower right-hand corner of the form.  This will take you to the next form.


About Part 2
About Explore Visual Basic - Part 2

Simple Animation Techniques

On the form for Part 2 you have an example of using picture boxes for simple animation techniques.  Animation is achieved by swapping different icons into the picture box.  The icons used in the animation are supplied in the icon library that comes with Microsoft Visual Basic.

Click the button labeled "Run Animation" to see this technique in action.

The "big picture" was created in Paintbrush and saved as a bitmap. Since the AutoSize property of PictureBox1 is set to "True" it will expand or shrink as needed to match the size of the picture being loaded into it.

Click the button labeled "Big Picture" to see an example of the use of AutoSize.

Using the Visible Property

By toggling the value of the visible property of the label area above the pictures, and by resetting the caption value of the label, you can make the label fit the situation.

The visible property of forms and picture boxes is used throughout Explore Visual Basic to make things appear and disappear.

Moving on

When you're done exploring this form, click the area marked Next in the lower right-hand corner of the form.  This will take you to the next form.


About Part 3
About Explore Visual Basic - Part 3

On the form for Part 3 you get a chance to explore the difference between option buttons and check boxes.

Option Buttons

Option buttons are used for mutually exclusive choices.

Try clicking the option button marked "Yellow" in Frame 1.  Now click the option button marked "White."

Notice that you cannot have both options active at once.

Now try clicking the button marked "Option3," then "Option4."

Again, you can't have both Option3 and Option4 active at once.

But you can have any single button from Frame1 active, and one of the option buttons directly on the form active at the same time.

This shows how to use a frame to create an "independent group" of option buttons.  All buttons inside a frame belong to a separate group.  All buttons created directly on a form belong to another a group.

Check Boxes

Check boxes can be used for "cumulative choices.

Try clicking the check box marked Bold and the check box marked Italic in Frame2.

Notice you can have every possible combination of check boxes checked at any one time.

Resetting the Form to its Original State

Check at least one of the check boxes and click the "Yellow" option button.  Then click the "Reset" button.

The click event procedure for the button marked Reset shows how you can call event procedures associated with the option buttons and check boxes from the event procedure of a different control.  You can look at the code provided with the project to see how this is done.

Moving on

When you're done exploring this form, click the area marked Next in the lower right-hand corner of the form.  This will take you to the next form.


About Part 4
About Explore Visual Basic - Part 4

Synchronizing Drive, Directory and File List Boxes.

Part 4 shows how you can make it easy for the users of your application to select a filename.

To pick the drive, click the "drop-down button on the drive box, then click on the drive you wish to select.

If you pick a floppy drive which doesn't currently have a disk in it, you 'll see that a bit of error handling has been added to account for that fact.  Just pick a valid drive and then proceed to the next step.

Look at the Drive1_Change event to see the associated code.

To pick the directory, scroll through the list, if necessary, till you find the directory you want.  Then double-click that directory.

Look at the Dir1_Change event to see how the directory and file paths are synchronized.

To pick the file, again scroll through the list if necessary till you find the filename you want.  Then double-click that filename.  You will see the name of the file you selected appear near the bottom of the form.

In the File1_DblClick event you'll see that you have to handle the root directory as a special case when building the complete path for the file selected.

Notice, also, that you typically select the file in the DblClick event instead of the click event, to guard against a user clicking just once by mistake. This follows standards users are familiar with, as well.

Moving on

When you're done exploring this form, click the area marked Next in the lower right-hand corner of the form.  This will take you to the next form.


About Part 5
About Explore Visual Basic - Part 5

List Boxes

This form displays a small list box that contains as entries the 3 possible styles of combo boxes.  This allows you to display an example of each style of combo box.  The items were added to the list box in the Form_Load procedure for Form 5.

Pick an entry from the list box by double-clicking one of the items in the box.

When you do so, the appropriate style of combo box appears below the list box and the first entry in the combo box is the value you would assign to the Style property of the combo box to create that type of control.

Combo Boxes

Dropdown Combo Box

A dropdown combo box initially displays only the text entry area and the dropdown button.  If you click the button you then see the rest of the list.

Simple Combo Box

A simple combo box initially displays at least part of the list (with a vertical scroll bar if needed), plus the text entry area.

Neither of these combo boxes has had code added to it to store new entries the user types in to the list.  If you have Visual Basic installed you can use the On-line Help information to find examples of how to accomplish this.

Dropdown List

A dropdown list is similar to the dropdown combo box except that there is no text entry area.  Therefore the user may not add new entries to the list, but only select from the existing items.

Double-click each of the list entries in turn to display each one of the combo box styles.

Click on the dropdown arrows to display lists.  Also try entering text or clicking on existing list entries.

Moving on

When you're done exploring this form, click the area marked Next in the lower right-hand corner of the form.  This will take you to the next form.


About Part 6
About Explore Visual Basic - Part 6

Timers

The form for Part 6 shows an example of using a timer to create a flashing graphical effect.

Try pressing the Start Timer and Stop Timer buttons to see what behavior the timer controls.

Remember that a timer is never visible on a form.  A bitmap of the timer control was created and then loaded into a picture box on the form.  The flashing effect is achieved by toggling the value of the Visible property of this picture box each time the timer goes off.  The timer's Interval property is measured in milliseconds.  (1000 milliseconds = 1 second.)

The caption of a label is also updated in the Timer1_Timer event procedure to display the current timer interval, which may be changed by using the scroll bars.

Scroll Bars

The properties you most typically manipulate on scroll bars are:

Max - which sets the maximum for the scroll bar's Value property

Min - which sets the minimum for the scroll bar's Value property

LargeChange - which sets the amount of change to the Value when the user clicks on the scroll bar

SmallChange- which sets the amount of change to the Value when the user clicks on the arrows at each end of the scroll bar

Try clicking  the horizontal scroll bar to change the value of the timer interval.

Try clicking  the vertical scroll bar to change the size  of the timer picture box.  Notice the bitmap in the picture box does not  change.

To accomplish this you would have to make a call a graphics routine in the  Windows API or swap in a bitmap which you had "stretched" with some type of paint program.  The background color of the picture box has been set  so you can compare the size of the bit map to the size of the growing or shrinking picture box.

Notice which end of each bar represents Max and which represents Min.  Note that as the timer interval increases it takes longer for you to see the results of your efforts.


A Note About Frames
A frame is used to group controls visually and functionally.

To place a control inside a frame, you must draw the control within the boundaries of the frame.  It will not work to drag a control onto a frame. This means that you must create the frame first, before you create the controls which will be placed inside it.


What are Control Arrays?
A control array is made up of a group of controls (or menu items) of the same type that share a common control name and event procedures.

 A specific control is referenced by specifying its index number.  For example:
  Label1(0).Caption = "Date"

A control array is typically used to conserve memory resources or to add new controls dynamically at run time.


Visual Basic Code Hint
Visual Basic statements MUST be on a single line.  If a code example in printed or on-line documentation shows a statement which is "wrapped" to multiple lines, it is due to display constraints only.
You may, if you wish,  include several statemets on a single line by using a colon (:) as a separator.